import { Module } from '@nestjs/common';
import { UploadModuleService } from './upload-module.service';
import { UploadModuleController } from './upload-module.controller';
import { MulterModule } from '@nestjs/platform-express';
import { diskStorage } from 'multer';
import { extname, join } from 'path';

@Module({
  imports: [MulterModule.register({
    storage: diskStorage({
       destination: join(__dirname, "../public/uploadimgs"),
       filename:(_, file, callback) => {
         const fileName = `${new Date().getTime() + extname(file.originalname)}`;
         return callback(null, fileName);
       }
    })
 })],
 controllers: [UploadModuleController],
  providers: [UploadModuleService]
})
export class UploadModuleModule {}
